


// 用户ID
let id = getUrlParam("id");
$(function () {
    GetUserRole();
});
//获取用户权限
function GetUserRole() {
    // let thisdata = [];
    // thisdata.push(InitRole(id));
    let USERdata = InitRole(id);
    if (USERdata != null) {
        initCom();
        InitData();

    }
    else OpenErrmsg("../../web/errhtml/404.html");
}
function initCom() {
    $('#cmb_Department').combobox({
        url: '',
        valueField: 'id',
        textField: 'text',
        onLoadSuccess: function (data) {
        }
    });
    $('#cmb_Status').combobox({
        url: '',
        valueField: 'id',
        textField: 'text',
        onLoadSuccess: function (data) {
        }
    });

}
// 重置按钮
function ReInitData() {
    $('#cmb_Department').combobox('setValue', '');
    $('#cmb_Status').combobox('setValue', '');
    $('#db_Start').datebox('setValue', GetDateStr(-7));
    $('#db_End').datebox('setValue', getCurrDate());
    InitData();
}
// 查询按钮
function InitData() {
    let queryvalue = $('#txt_Search').textbox('getValue');
    let Department = $('#cmb_Department').combobox('getValue');
    let Status = $('#cmb_Status').combobox('getValue');
    let StartDate = $('#db_Start').datebox('getValue');
    let EndDate = $('#db_End').datebox('getValue');
    let monthcount = DateDiff(StartDate, EndDate) / 31;
    if (StartDate != "" && EndDate != "" && monthcount > 3) {
        $.messager.alert('警告', '查询日期不能超过三个月！');
    } else {
        //后台返回数据
        var data = [
            { "ID": "B01", "The_Date": "2021-09-08", "Rectify_Type": "隐患", "Rectify_Content": "整改内容", "Department": "生产部", "Rectify_By": "张丹", "Status": "完成" },
            { "ID": "B01", "The_Date": "2021-09-08", "Rectify_Type": "隐患", "Rectify_Content": "整改内容", "Department": "生产部", "Rectify_By": "张丹", "Status": "完成" },
            { "ID": "B01", "The_Date": "2021-09-08", "Rectify_Type": "隐患", "Rectify_Content": "整改内容", "Department": "生产部", "Rectify_By": "张丹", "Status": "完成" },
            { "ID": "B01", "The_Date": "2021-09-08", "Rectify_Type": "隐患", "Rectify_Content": "整改内容", "Department": "生产部", "Rectify_By": "张丹", "Status": "完成" },
            { "ID": "B01", "The_Date": "2021-09-08", "Rectify_Type": "隐患", "Rectify_Content": "整改内容", "Department": "生产部", "Rectify_By": "张丹", "Status": "完成" },
        ];
        //加载数据
        $('#dg_WorkPlanList').datagrid({
            data: data
        });
    }
}
function choose2() {
    var isok = $("#ck_search").is(':checked');
    if (isok) {
        $("#div_Search").show();
        $('#db_Start').datebox('setValue', GetDateStr(-7));
        $('#db_End').datebox('setValue', getCurrDate());
    }
    else {
        $("#div_Search").hide();
        $('#db_Start').datebox('setValue', "");
        $('#db_End').datebox('setValue', "");
    }
}
// function formaterPlanWork(value, row) {
//     let str = ' <label style="color:#589BD8">'+row.PlanWork+'</label><br />';
//      str += ' <label style="padding:10px">发起人&nbsp;&nbsp;&nbsp;   '+row.Creater+'</label>';
//      str += ' <label style="padding:10px">发起时间&nbsp;&nbsp;&nbsp;    '+row.CreateDate+'</label>';
//     return str;
// }
// function formaterIndex(value, row) {
//     return '<a href="#" style="color:#027DB4;text-decoration:none;margin-top: 20px;">处理</a>';
// }
